package BufferedStream;

import java.io.*;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        /*
         *   需求：
         *       利用字节缓冲流拷贝文件
         *
         *   字节缓冲输入流的构造方法：
         *           public BufferedInputStream(InputStream is)
         *
         *    字节缓冲输出流的构造方法：
         *           public BufferedOutputStream(OutputStream os)
         *
         * */

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("copy2.txt"));

        byte[] bytes = new byte[1024];
        int len = 0;

        // 拷贝,一次读写多个数据
        while((len = bis.read(bytes)) != -1){
            bos.write(bytes,0,len);
        }

        // 释放资源
        bos.close();
        bis.close();
    }
}
